%%%-----------------------------------
%%% @Module  : pt_28
%%% @Author  : xws
%%% @Created : 2017.1.4
%%% @Description: pt_28
%%%-----------------------------------
-module(pt_28).
-export([read/2, write/2]).
-include("common.hrl").
-include("proto_27_share_shop.hrl").

%%
%%客户端 -> 服务端 ----------------------------
%%

%% 28000 获取活动信息
read(28000, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operaty_info, Bin),
	{c2s_operaty_info, UID} = ClientData,
	{ok, [UID]};

%% 28001 获取活动状态信息
read(28001, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_get_operaty_state, Bin),
    {c2s_get_operaty_state, UID} = ClientData,
    {ok, [UID]};

%% 28100 领取活动奖励
read(28100, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_give_operaty_reward, Bin),
	{c2s_give_operaty_reward, SubID} = ClientData,
	{ok, [SubID]};

%% 28101 比赛分享
read(28101, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_share_game, Bin),
	{c2s_share_game, SubID, Data} = ClientData,
	{ok, [SubID, Data]};

%% 28003 获取运营活动1数据
read(28003, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operacty_1_get_data, Bin), 
    {c2s_operacty_1_get_data ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28002 免费抽奖
read(28002, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_1_free_draw, Bin), 
    {c2s_operaty_1_free_draw ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28021 集字兑换
read(28021, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_2_collect_word_exchange, Bin), 
    {c2s_operaty_2_collect_word_exchange, ExchangeId} = ClientData,
    {ok, [ExchangeId]};

%% 28041 获取在线奖励信息
read(28041, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operaty_3_online, Bin),	
	{c2s_operaty_3_online ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28042 获取在线奖励活动奖励
read(28042, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operate_3_reward, Bin),	
	{c2s_operate_3_reward ,Playerid} = ClientData,
    {ok, [Playerid]};

%% =============================

%% 28061 获取幸运基金活动信息
read(28061, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operaty_4_luckyfund, Bin),	
	{c2s_operaty_4_luckyfund ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28062 幸运基金抽奖
read(28062, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operaty_4_draw, Bin),	
	{c2s_operaty_4_draw ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28063 领取幸运基金奖励
read(28063, Bin) ->
	{ClientData, _} = proto_read:unpack(c2s_operaty_4_reward, Bin),	
	{c2s_operaty_4_reward ,Playerid} = ClientData,
    {ok, [Playerid]};


%% 28082 领取新春红包
read(28082, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_5_pick_redpack, Bin), 
    {c2s_operaty_5_pick_redpack ,Playerid} = ClientData,
    {ok, [Playerid]};

%% 28121 获取幸运转盘数据
read(28121, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_8_get_data, Bin), 
    {c2s_operaty_8_get_data, Playerid} = ClientData,
    {ok, [Playerid]};

%% 28122 进行抽奖
read(28122, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_8_draw, Bin), 
    {c2s_operaty_8_draw, DrawType} = ClientData,
    {ok, [DrawType]};

%% 28123 进行抽奖
read(28123, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_operaty_8_refresh_draw, Bin), 
    {c2s_operaty_8_refresh_draw, PlayerId} = ClientData,
    {ok, [PlayerId]};

%% 28151 超级翻翻乐翻牌
read(28151, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_herocraft_twice_draw, Bin), 
    {c2s_herocraft_twice_draw, UID} = ClientData,
    {ok, [UID]};

%% 28161 许愿－信息
read(28161, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_oper_wish_info, Bin), 
    {c2s_oper_wish_info, UID} = ClientData,
    {ok, [UID]};


%% 28162 许愿
read(28162, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_oper_wish_req, Bin), 
    {c2s_oper_wish_req, Type} = ClientData,
    {ok, [Type]};


%% 28163 领奖
read(28163, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_oper_wish_ward, Bin), 
    {c2s_oper_wish_ward, UID} = ClientData,
    {ok, [UID]};

%% 七天红包
read(28171, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_oper_7days_info, Bin), 
    {c2s_oper_7days_info, UID} = ClientData,
    {ok, [UID]};


read(28173, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_oper_task_lottery, Bin), 
    {c2s_oper_task_lottery, Days,TaskId} = ClientData,
    {ok, [Days,TaskId]};


read(28174, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_redpack_histroy, Bin), 
    {c2s_redpack_histroy, UID} = ClientData,
    {ok, [UID]};

read(_Cmd, _R) ->
    ?ERROR_MSG("~s pt_28 reading cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), _Cmd, _R]),
    {error, no_match}.

%%
%%服务端 -> 客户端 ------------------------------------
%%

%% 28000 获取活动信息
write(28000,  [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_info, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28000, ServerData)};

%% 28001 获取活动信息
write(28001,  [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_operaty_state, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28001, ServerData)};

%% 28100 获取活动奖励
write(28100,  [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_give_operaty_reward, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28100, ServerData)};

%% 28101 分享活动
write(28101,  [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_share_game, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28101, ServerData)};

%% 28102 广播活动信息
write(28102,  [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_notify_operaty_info, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28102, ServerData)};

%% 28003 获取运营活动1数据
write(28003, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operacty_1_get_data, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28003, ServerData)};

%% 28002 免费抽奖
write(28002, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_1_free_draw, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28002, ServerData)};

%% 28021 集字兑换
write(28021, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_2_collect_word_exchange, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28021, ServerData)};

%% 28041 获取在线领奖信息
write(28041, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_3_online, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28041, ServerData)};

%% 28042 领取奖励
write(28042, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operate_3_reward, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28042, ServerData)};

%% ====================

%% 28061 获取幸运基金活动信息
write(28061, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_4_luckyfund, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28061, ServerData)};

%% 28062 幸运基金抽奖
write(28062, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_4_draw, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28062, ServerData)};

%% 28063 领取幸运基金奖励
write(28063, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_4_reward, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28063, ServerData)};

%% 28081 推送玩家触发新春红包
write(28081, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_5_redpack, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28081, ServerData)};

%% 28082 领取新春红包
write(28082, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_5_pick_redpack, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28082, ServerData)};

%% 28121 获取幸运转盘数据
write(28121, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_8_get_data, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28121, ServerData)};

%% 28122 进行抽奖
write(28122, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_8_draw, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28122, ServerData)};

%% 28123 刷新抽奖
write(28123, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_operaty_8_refresh_draw, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28123, ServerData)};

%% 28151 超级翻翻乐抽奖
write(28151, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_herocraft_twice_draw, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28151, ServerData)};


%% 28161 信息
write(28161, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_wish_info, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28161, ServerData)};

%% 28162 请愿
write(28162, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_wish_req, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28162, ServerData)};

%% 28163 领奖
write(28163, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_wish_ward, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28163, ServerData)};

%% 28171 信息
write(28171, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_7days_info, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28171, ServerData)};

%% 28172 变更
write(28172, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_task_modify, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28172, ServerData)};

%% 28173 领奖
write(28173, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_oper_task_lottery, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28173, ServerData)};


write(28174, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_redpack_histroy, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(28174, ServerData)};

write(Cmd, _R) ->
    ?ERROR_MSG("~s pt_28 writting cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), Cmd, _R]),
    {ok, pt:pack(0, <<>>)}.
